package com.cc.mapper;

import com.cc.pojo.EmpQueryParam;
import com.cc.pojo.Student;
import com.cc.pojo.StudentCountDate;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface StudentMapper {

    List<Student>  list(EmpQueryParam empQueryParam);

    void delect(List<Integer> ids);

    void add(Student student);
    @Select("select * from student where id=#{id}")
    Student getID(Integer id);

    void update(Student student);

    @Select("""
        select
                    case degree
                        when 1 then '初中'
                        when 2 then '高中'
                        when 3 then '大专'
                        when 4 then '本科'
                        when 5 then '硕士'
                        when 6 then '博士'
                        else '其他'
                        end as name,
                    count(*) as value
                from student
                group by degree
""")
    List<Map> getStudentDegreeData();

@Select("""
        SELECT
        c.id AS clazzId,
        c.name AS className,
        COUNT(s.id) AS num
        FROM clazz c
        LEFT JOIN student s ON c.id = s.clazz_id
        GROUP BY c.id, c.name
        ORDER BY num DESC
        """)
    List<StudentCountDate> getStudentCountData();


    int weiji(Map<String, Object> map);

}
